<extend name="public@base5"/>
<block name="main">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link active" href="{:url('Audit/index')}">审核列表</a>
            </li>
        </ul>
        <form class="well form-inline margin-top-20 bg-white" method="get" action="{:url('Audit/index')}">
            提交时间:
            <input type="text" class="js-bootstrap-date form-control form-check-inline" name="start_time"
                value="{$start_time|default=''}"
                style="width: 140px;" autocomplete="off">-
            <input type="text" class="js-bootstrap-date form-control form-check-inline" name="end_time"
                value="{$end_time|default=''}"
                style="width: 140px;" autocomplete="off"> 
            &nbsp;
            <input type="text" class="form-control form-check-inline" name="user_id" style="width: 200px;"
                value="{$user_id|default=''}" placeholder="请输入用户ID">
            &nbsp;
            <input type="text" class="form-control form-check-inline" name="mobile" style="width: 200px;"
                value="{$mobile|default=''}" placeholder="请输入手机号码">
            审核状态:
            <select class="form-control form-check-inline" name="audit_status" style="width: 140px;">
                <option value='0'>待审核</option>
                <option value='1'>已通过</option>
                <option value='2'>已驳回</option>
            </select> &nbsp;
            <input type="submit" class="btn btn-primary" value="搜索"/>
            <a class="btn btn-danger" href="{:url('Audit/index')}">清空</a>
        </form>
        <table class="table table-hover table-bordered margin-top-20">
            <thead>
            <tr>
                <th width="50">序号</th>
                <th>用户ID</th>
                <th>手机号</th>
                <th>提交内容</th>
                <th>提交时间</th>
                <th>审核状态</th>
                <th width="120">{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            <php>
                $audit_statuses=['待审核', '已通过', '已驳回'];
            </php>
            <foreach name="items" item="vo">
                <tr>
                    <td>{$vo.id}</td>
                    <td>{$vo.user_id}</td>
                    <td>{$vo.mobile}</td>
                    <td>
                        <empty name="vo.audit_avatar">
                        <else/>
                            <a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.audit_avatar)}');">
                                <img width="50" height="50" src="{:cmf_get_image_url($vo.audit_avatar)}">
                            </a>
                        </empty>
                        {$vo.audit_nickname}
                    </td>

                    
                    <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
                    <td>                        
                        <switch name="vo.audit_status">
                            <case value="0">
                                <span class="badge text-bg-warning">{$audit_statuses[$vo['audit_status']]}</span>
                            </case>
                            <case value="1">
                                <span class="badge text-bg-success">{$audit_statuses[$vo['audit_status']]}</span>
                            </case>
                            <case value="2">
                                <span class="badge text-bg-danger">{$audit_statuses[$vo['audit_status']]}</span>
                            </case>
                        </switch>
                    </td>

                    <td>
                        <a href="javascript:"
                            onclick="openAuditDialog(this, '{$vo.audit_status}')"
                            data-href="{:url('audit/detail', array('id'=>$vo['id'], 'mobile'=>$vo['mobile']))}"
                            title="审核" data-toggle="tooltip">
                            <if condition="$vo.audit_status == 0">审核<else/>审核结果</if>
                        </a>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </div>
</block>
<block name="scripts">
    <script>
        function openAuditDialog(obj, auditStatus) {
            var $obj = $(obj);
            var href = $obj.data('href');
            console.log(href);
            parent.openIframeLayer(href, auditStatus == 0 ? "审核" : "审核结果", {
                area: GV.IS_MOBILE ? ['100%', '100%'] : ['50%', '360px'],
                offset: GV.IS_MOBILE ? ['0px', '0px'] : 'auto',
                // btn: auditStatus == 0 ? ['确定', '取消'] : ['重新审核', '关闭'],
                yes: function (index, layero) {
                    console.log(layero);
                    var iframeWin = parent.window[layero.find('iframe')[0]['name']];
                    //iframeWin.confirm();
                    parent.layer.close(index); //如果设定了yes回调，需进行手工关闭
                },
                end: function () {
                    parent.location.reload();
                }
            });
        }
    </script>
</block>
